home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / mint / utilit~1 / initsnb.zoo / init / sh / lastdump < prev    next >
Encoding:
Text File  |  1992-09-09  |  1.1 KB  |  44 lines

  1. #! /bin/sh
  2. # lastdump: find out when a file was last dumped
  3. # Usage: lastdump regexp
  4. # The regular expression must be in grep syntax, not in shell syntax
  5. root=u:
  6. PATH=/bin:/usr/bin
  7. program=`basename $0`
  8.  
  9. infofile=$root/etc/dumpinfo
  10.  
  11. if test $# -eq 0 ; then
  12.   echo usage: $program file-regexp \(grep syntax, not shell\)
  13.   exit 1
  14. fi
  15.  
  16. if test ! -f $infofile ; then
  17.   echo $program: Cannot find dump information file $infofile
  18.   exit 1
  19. fi
  20.  
  21. for regexp in $* ; do
  22.   gawk '
  23.     BEGIN {
  24.       found = 0;
  25.     }
  26.     $0 ~ /^Level [0-9]+ dump of [^ ]+ started on [^ ]+ [^ ]+$/ {
  27.       found_here = 0; level = $2; device = $5; startdate = $8; starttime = $9;
  28.     }
  29.     $0 ~ /^Level [0-9]+ dump of [^ ]+ ended on [^ ]+ [^ ]+ \(written on [^ ]+\)$/ {
  30.       if (found_here)
  31.         printf "Dump file: %s\n", substr ($12, 1, length ($12) - 1);
  32.     }
  33.     $8 ~ regexp {
  34.       found = 1; found_here = 1;
  35.       printf "%s: Dumped %s %s, level %d dump of %s\n", $8, startdate,
  36.               starttime, level, device;
  37.     }
  38.     END {
  39.       if (!found)
  40.         printf "Nothing matching \"%s\" ever dumped\n", regexp;
  41.     }
  42.   ' regexp=$regexp $infofile
  43. done
  44.